]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
windowManager: Use g-s-d wacom dbus helpers to update pad leds/oleds
authorCarlos Garnacho <carlosg@gnome.org>
Wed, 28 Dec 2016 12:03:53 +0000 (13:03 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Fri, 10 Feb 2017 22:55:04 +0000 (23:55 +0100)
This keeps feedback on the device itself in sync with the overall pad
state, a feature we had previously through g-s-d.

https://bugzilla.gnome.org/show_bug.cgi?id=776543

js/ui/windowManager.js

index 624eb736cf10e1beb16cae219faccb68637ab295..324927f6886cd4f266a8400ad17aadf0723578c6 100644 (file)
@@ -33,6 +33,25 @@ const UNDIM_TIME = 0.250;
 const DISPLAY_REVERT_TIMEOUT = 20; // in seconds - keep in sync with mutter
 const ONE_SECOND = 1000; // in ms
 
+const GSD_WACOM_BUS_NAME = 'org.gnome.SettingsDaemon.Wacom';
+const GSD_WACOM_OBJECT_PATH = '/org/gnome/SettingsDaemon/Wacom';
+
+const GsdWacomIface = '<node name="/org/gnome/SettingsDaemon/Wacom"> \
+<interface name="org.gnome.SettingsDaemon.Wacom"> \
+  <method name="SetGroupModeLED"> \
+    <arg name="device_path" direction="in" type="s"/> \
+    <arg name="group" direction="in" type="u"/> \
+    <arg name="mode" direction="in" type="u"/> \
+  </method> \
+  <method name="SetOLEDLabels"> \
+    <arg name="device_path" direction="in" type="s"/> \
+    <arg name="labels" direction="in" type="as"/> \
+  </method> \
+  </interface> \
+</node>';
+
+const GsdWacomProxy = Gio.DBusProxy.makeProxyWrapper(GsdWacomIface);
+
 const DisplayChangeDialog = new Lang.Class({
     Name: 'DisplayChangeDialog',
     Extends: ModalDialog.ModalDialog,
@@ -925,6 +944,30 @@ const WindowManager = new Lang.Class({
             Main.osdWindowManager.show(monitorIndex, icon, label, null);
         }));
 
+        this._gsdWacomProxy = new GsdWacomProxy(Gio.DBus.session, GSD_WACOM_BUS_NAME,
+                                                GSD_WACOM_OBJECT_PATH,
+                                                Lang.bind(this, function(proxy, error) {
+                                                    if (error) {
+                                                        log(error.message);
+                                                        return;
+                                                    }
+                                                }));
+
+        global.display.connect('pad-mode-switch', Lang.bind(this, function (display, pad, group, mode) {
+            let labels = [];
+
+            //FIXME: Fix num buttons
+            for (let i = 0; i < 50; i++) {
+                let str = display.get_pad_action_label(pad, Meta.PadActionType.BUTTON, i);
+                labels.push(str ? str: '');
+            }
+
+            if (this._gsdWacomProxy) {
+                this._gsdWacomProxy.SetOLEDLabelsRemote(pad.get_device_node(), labels);
+                this._gsdWacomProxy.SetGroupModeLEDRemote(pad.get_device_node(), group, mode);
+            }
+        }));
+
         Main.overview.connect('showing', Lang.bind(this, function() {
             for (let i = 0; i < this._dimmedWindows.length; i++)
                 this._undimWindow(this._dimmedWindows[i]);